package pers.wensheng.patterns.behavioral_pattern.iterator_pattern.my_impl.entity;

import pers.wensheng.patterns.behavioral_pattern.iterator_pattern.my_impl.Student;
import java.util.ArrayList;
import java.util.List;

/**
 *  学生聚合
 */
public class StudentAggregateImpl implements StudentAggregate {

    private List<Student> list = new ArrayList<>();

    /**
     * @param student
     */
    @Override
    public void addStudent(Student student) {
        list.add(student);
    }

    /**
     * @param student
     */
    @Override
    public void removeStudent(Student student) {
        list.remove(student);
    }

    /**
     * 获取迭代器对象
     * @return
     */
    @Override
    public StudentIterator getStudentIterator() {
        return new StudentIteratorImpl(list);
    }
}
